<!DOCTYPE html>

<script src="../../../resources/js-test.js"></script>

<script>
description('MutationObserver wrappers should survive GC for passing into the callback even if JS has lost references and the only remaining observations are transient.');

jsTestIsAsync = true;

function addObserver(node, fn) {
    var observer = new MutationObserver(fn);
    observer.testProperty = true;
    observer.observe(node, {attributes:true, subtree: true});
}

onload = function() {
    var root = document.createElement('div');
    var child = root.appendChild(document.createElement('span'));
    addObserver(root, function(records, observer) {
        window.observer = observer;
        shouldBe('observer.testProperty', 'true');
        finishJSTest();
    });

    root.removeChild(child);
    child.setAttribute('foo', 'bar');
    root = null;

    gc();
};
</script>

